const Git = require("./git");
const { readdir } = require('fs/promises')
module.exports = class TyGitCrud {
    constructor(rootDirPath) {
        this.rootDirPath = rootDirPath
    }

    async allRepo() {
        const list = await readdir(this.rootDirPath)
        return list
    }

    async fileIndexList(repoName, branchName) {
        const git = new Git(this.rootDirPath, repoName)
        const indexTree = await git.lastestTreeByBranch(branchName)
        const list = await git.ls(indexTree)
        return list;
    }

    async allBranch(repoName) {
        const git = new Git(this.rootDirPath, repoName)
        const list = await git.branch()
        return list;
    }

    async allCommit(repoName, branchName) {
        const git = new Git(this.rootDirPath, repoName)
        const list = await git.log(branchName)
        return list;
    }

}